<template>
  <div>
    <Carousel :imgs="bannerList" :autoplay="false" :showButton="true"> </Carousel>
    <h3>推荐歌单</h3>
    <div class="playlist-wrap">
      <play-list :data="item" v-for="item in hightQuality" :key="item.id" class="play-list-item" @click="clickPlayList"></play-list>
    </div>
    <a-pagination show-quick-jumper :default-current="2" :total="500" @change="onChange" />
  </div>


</template>

<script>
  import {_getBanner, _getHightQuality} from '@/api/discover.js'
  export default {
    data(){
      return {

      }
    },
    async asyncData({params, route, error}){
      const banner = await _getBanner()
      const hightQuality = await _getHightQuality()
      return { bannerList: banner.banners.map(item => item.imageUrl),
                hightQuality: hightQuality.playlists
      }
    },
    created() {
    },
    methods:{
      onChange(page){
        console.log('page', page)
      },
      // 点击歌单
      clickPlayList(data){
        console.log('clickplay', data)
        this.$router.push('/playListDetail?id=' + data.id)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .ant-carousel >>> .slick-slide {
    text-align: center;
    height: 160px;
    line-height: 160px;
    background: #364d79;
    overflow: hidden;
  }

  .ant-carousel >>> .slick-slide h3 {
    color: #fff;
  }
  .playlist-wrap {
    display: flex;
    flex-wrap: wrap;

    .play-list-item {
      margin-right: 24px;
      margin-bottom: 20px;
    }

    .play-list-item:nth-child(5n) {
      margin-right: 0px;
    }
  }
</style>
